package com.aos.erp.schools.rest.car;


import com.aos.erp.common.bean.PageBean;
import com.aos.erp.common.bean.ResultEntity;
import com.aos.erp.common.constant.GlobalConstant;
import com.aos.erp.schools.enums.student.IsDel;
import com.aos.erp.schools.model.car.CarPicture;
import com.aos.erp.schools.service.car.CarPictureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(value = "车辆图片", tags = {"车辆图片API"})
@RestController("RESTCarPictureController")
@RequestMapping("/api/carPicture")
public class CarPictureController {
    @Resource
    private CarPictureService carPictureService;

    @ApiOperation(value = "获取车辆图片", notes = "获取车辆图片")
    @RequestMapping(value = "/getInfo", method = RequestMethod.POST)
    public ResultEntity getInfo(String carId, String type) throws Exception {
        if (StringUtils.isBlank(carId)) {
            return ResultEntity.failed("车辆ID不能为空", ResultEntity.CODE_NULL);
        }
        Map<String, Object> map = carPictureService.queryList(carId, type);
        return ResultEntity.success(map);
    }

    @ApiOperation(value = "删除车辆图片", notes = "删除车辆图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fileId", value = "车辆图片文件id", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public ResultEntity delete(String fileId) throws Exception {
        if (StringUtils.isBlank(fileId)) {
            return ResultEntity.failed("车辆图片ID不能为空", ResultEntity.CODE_NULL);
        }
        return carPictureService.updateObject(fileId) >= 1 ? ResultEntity.success() : ResultEntity.failed();
    }

}

